package woaini.wind.bot.rasa.action;

import woaini.wind.bot.rasa.base.Action;
import woaini.wind.bot.rasa.base.CollectingDispatcher;
import woaini.wind.bot.rasa.base.domain.Domain;
import woaini.wind.bot.rasa.base.event.Event;
import woaini.wind.bot.rasa.base.exception.RejectExecuteException;
import woaini.wind.bot.rasa.base.message.Message;
import woaini.wind.bot.rasa.base.tracker.Tracker;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Slf4j
public class WeatherFormSubmitAction implements Action {
  @Override
  public String name() {
    return "action_weather_form_submit";
  }

  @Override
  public List<? extends Event> run(CollectingDispatcher dispatcher, Tracker tracker, Domain domain) throws RejectExecuteException {

    String address = tracker.getStringSlot("address");
    String dateTime = tracker.getStringSlot("date-time");

    log.info("{}->{}",dateTime,address);

    dispatcher.utterMessage(Message.builder().text(STR."\{dateTime}->\{address}").build());
    return List.of();
  }
}
